//
//  NSDictionary+Property.m
//  彩票
//
//  Created by liupan on 2016/12/11.
//  Copyright © 2016年 liupan. All rights reserved.
//

#import "NSDictionary+Property.h"

@implementation NSDictionary (Property)
//生成属性代码 ==>根据字典中所有key
- (void)createPropertyCode{
    NSMutableString *codes = [NSMutableString string];
    
    [self enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull value, BOOL * _Nonnull stop) {
        NSString *code;
        if ([value isKindOfClass:[NSString class]]) {
            
        code = [NSString stringWithFormat:@"@property (nonatomic,string)NSString *%@;",key];
            
        }else if ([value isKindOfClass:NSClassFromString(@"__NSCFBoolean")]){
            
        code = [NSString stringWithFormat:@"@property (nonatomic,strong)NSArray *%@;",key];
            
        }else if ([value isKindOfClass:[NSNumber class]]){
            
        code = [NSString stringWithFormat:@"@property (nonatomic,assign)NSInteger *%@;",key];
            
        }else if ([value isKindOfClass:[NSDictionary class]]){
            
        code = [NSString stringWithFormat:@"@property (nonatomic,strong)NSDictionary *%@;",key];
            
        }else if ([value isKindOfClass:[NSArray class]]){
            
        code = [NSString stringWithFormat:@"@property (nonatomic,strong)NSArray *%@;",key];
            
        }
        [codes appendFormat:@"\n%@\n",code];
    }];

    NSLog(@"%@",codes);
}
@end
